function curveSum=MultiPeaksMultiCurves(pars,w)
% ===============================================
% Schniepp Lab, 2018-2021
% Used for evaluate the sum of multiple curves
% Parameters:
% m - number of curves
% n - number of peaks
% dimension of pars:
% (m*2+3)*n
% positions - positions for each sub-peak,
%     first line in pars
% width - width for each sub-peak
%     second line in pars
% L - Lorenzian percentage for each sub-peak
%     third line in pars
% Rest of pars:
% curve 1 AG
% curve 1 AL
% curve 2 AG
% curve 2 AL
% ...
% curve n AG
% curve n AL
% ===============================================
    
    [a,n]=size(pars);
    c=max(size(w));
    m=(a-3)/2;
    curveSum=zeros(c,m);
    positions=pars(1,:);
    width=pars(2,:);
    L=pars(3,:);
    AGL=pars(4:end,:);
    for i=1:m
        curve=0;
        for j=1:n
            temp=GaussianLorenzNew(AGL(i*2-1,j),AGL(i*2,j),width(1,j),positions(1,j),L(1,j),w);
            curve=curve+temp;
        end
        curveSum(:,i)=curve;
    end
end